﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Win32;
using Wise.TimeWarrior.DTO;
using Wise.TimeWarrior.Impl;
using Wise.TimeWarrior.Interfaces;
using Wise.TimeWarrior.OSFunctionalitiesProxy;

namespace TimeWarrior.Test
{
    [TestClass]
    public class SystemUsageTest
    {
        [TestMethod]
        public void WatchForAction()
        {
            Moq.Mock<IUserSessionSystemEvents> usseMock = new Moq.Mock<IUserSessionSystemEvents>(); 

            ISystemUsage conf = new SystemUsageService(usseMock.Object);
            conf.StartWatchForUserStatus();

            Assert.AreEqual(1, conf.Events.Count);
            Assert.AreEqual(SessionSwitchReasonExtended.ProgramStarted, conf.Events[0].UserAction);
            Assert.IsNotNull(conf.Events[0].ProcessList);
            
            usseMock.Raise(x =>x.SessionSwitched+= null, new object[]{null , new SessionSwitchEventArgs(SessionSwitchReason.SessionLogoff)} );
            conf.StopWatchForUserStatus();

            Assert.AreEqual(3, conf.Events.Count);
            Assert.AreEqual(SessionSwitchReasonExtended.SessionLogoff, conf.Events[1].UserAction);
            Assert.IsNotNull(conf.Events[1].ProcessList);



        }
    }
}
